package leetcode_601_700;

import java.sql.Array;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class LeeCode_682 {
    public static void main(String[] args) {

    }
    private static int calPoints(String[] operations) {
        LinkedList<Integer> list = new LinkedList<>();
        for (String op : operations) {
            switch (op) {
                case "+":
                    list.add(list.get(list.size() - 1) + list.get(list.size() - 2));
                    break;
                case "C":
                    list.removeLast();
                    break;
                case "D":
                    list.add(list.get(list.size() - 1) * 2);
                    break;
                default:
                    list.add(Integer.parseInt(op));
                    break;
            }
        }
        int ans = 0;
        for (Integer integer : list) {
            ans += integer;
        }
        return ans;
    }
}
